import { UserService } from "./../../providers/UserService";
import { Component } from "@angular/core";
import { IonicPage, NavController, NavParams,AlertController } from "ionic-angular";
import { PIC_URL } from "./../../providers/Config";
/**
 * Generated class for the ShopOverPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: "page-shop-over",
  templateUrl: "shop-over.html"
})
export class ShopOverPage {
  /*passOver传向子组件的值*/
  passOver={
    ErweiM:'',
    PayCode:'',
    sellec_logo:'',
    sellec_name:'',
    Mydeta:'2018.12.31'
  }
  sellec_name = "未知";
  sellec_logo = "";
  picrooturl = PIC_URL;
  Order_dd = {
    order_sn: "MJS_1522219098a6f791"
  };
  Mydeta:'2018.12.31'
  erweiM = "";
  PayCode = "";
  user: any;
  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
    public navserver: UserService,
    public alertCtrl: AlertController
  ) {}

  ionViewDidLoad() {
    console.log("ionViewDidLoad ShopOverPage");
    this.erwei();
    this.seller();
  }
  showAlert() {
    let alert = this.alertCtrl.create({
      title: '获取失败',
      subTitle: '请返回重试',
      buttons: ['OK']
    });
    alert.present();
  }

  /*获取后台二维码*/
  async erwei() {
    let er = await this.navserver.setQrCodeAPI(this.Order_dd);
    console.log(this.Order_dd);
    
    console.log(er);
    if(er.code==1){
       this.erweiM = er.data["QRcode"];
      // this.PayCode = er.data["payCode"];
     this.passOver.ErweiM=er.data["QRcode"]
     this.passOver.PayCode=er.data["payCode"]
     console.log(this.passOver.ErweiM)
    }else{
      this.showAlert()
    }
  }
  /*用户相关数据*/ 
  seller() {
    this.user = this.navParams.data;
    // this.sellec_logo = this.user.shop_logo;
    // this.sellec_name = this.user.shop_name;
    this.passOver.sellec_logo= this.user.shop_logo;
    this.passOver.sellec_name=this.user.shop_name;
    console.log(this.user)
  }

  Goroot(){
    this.navCtrl.popToRoot()
  }
}
